function dialogMoveToEmployee(getNew) {
    
    $.ajax({
       "url" : 'a_dialog_move_to_employee',
       "data" : {"getNew":getNew},
       "type" : 'GET',
       "success" : function (html) {
           $.Dialog({
              "title": "Сменить пользователя оборудования...",
              "draggable": true,
              "content": html,
              "onShow" : function() {
                  $('#move_employee_id').val(0);
                    setDatepickerDefDate('move_employee_date');
              },
              "width":450
           });
       }
    });
    
    
    
}

function mteOfficeChanged() {
    var select = document.getElementById('dialog_mte_select_office');
    var officeId = select.value;
    var emplSelect = document.getElementById('dialog_mte_select_employee');
    emplSelect.innerHTML = '<option value=\"-1\">Выберите сотрудника</option>\n';
    emplSelect.selectedIndex = 0;
    if (officeId !== 'NONE') {
        select.options[0].disabled = true;
        document.getElementById('move_office_id').value = officeId;
        $.ajax({
           "url":'a_get_working_employees_from',
           "data":{"officeId":officeId},
           "type":'GET',
           "dataType":'json',
           "success":function(data) {
               if (data.length != null) {
                    for(var i=0;i<data.length;i++) {
                        emplSelect.innerHTML += '<option value=\"' + data[i].id + '\">' + data[i].surnameNamePatronymic + '</option>\n';
                    }
               }
           }
        });
    }
}

function mteEmployeeChanged() {
   var emplSelect = document.getElementById('dialog_mte_select_employee');
   var emplId = emplSelect.value;
   document.getElementById('move_employee_id').value = emplId;
}

function submitMoveToEmployee() {
    var selectedRow = $('#component_table .row_selected')[0];
    var emplId = document.getElementById('move_employee_id').value;
    var offcId = document.getElementById('move_office_id').value;
    var date = $('#move_employee_date').val();
    if (emplId < 0) {
        $.Notify({
            "content": 'Выберите сотрудника',
            "style": {"background": 'darkred', "color": 'white', "font": 'bold'},
            "timeout": 8000
        });
    } else {
        $.ajax({
           "url":'a_dialog_move_to_employee',
           "data":{"compId":selectedRow.id,"emplId":emplId,"date":date,"offcId":offcId},
           "type":'POST',
           "dataType":'json',
           "success": function(json) { 
                notifyUpdateResult({
                   "errorVal":json.errorVal,
                   "successMessage":'Оборудование перемещено.',
                   "dataTableId":'component_table',
                   "datepickerId":'move_employee_date'
                });
           }
        });
    }
}